import axios from '../utils'
const api = {
  campaignsCreative: '/campaigns-creative',
  changeState: '/campaigns-creative/change_state',
  copyCreative: '/campaigns-creative/copy',
  getAllDataByPage: '/campaigns-creative/getAllDataByPage',
  getDetailedDataByPage: '/sys/getDetailedDataByPage',
  setDetailedState: '/sys/change_detailed_state'
}

export default api

export function changeState(parameter) {
  return axios({
    url: api.changeState,
    method: 'get',
    params: parameter
  })
}


//复制广告系列
export function copyCreative(parameter) {
  return axios({
    url: api.copyCreative,
    method: 'post',
    data: parameter
  })
}


export function getAllDataByPage(parameter) {
  return axios({
    url: api.getAllDataByPage,
    method: 'get',
    params: parameter
  })
}


//分页查询广告系列信息通过详细状态查询，公司最高权限用户才有此功能
export function getDetailedDataByPage(parameter) {
  return axios({
    url: api.getDetailedDataByPage,
    method: 'get',
    params: parameter
  })
}

export function setDetailedState(parameter) {
  return axios({
    url: api.setDetailedState,
    method: 'get',
    params: parameter
  })
}


export function updateCampaignsCreative(parameter) {
  return axios({
    url: api.campaignsCreative,
    method: 'put',
    data: parameter
  })
}

export function addCampaignsCreative(parameter) {
  return axios({
    url: api.campaignsCreative,
    method: 'post',
    data: parameter
  })
}

export function getCampaignsCreative(parameter, userId) {
  return axios({
    url: api.campaignsCreative + parameter,
    method: 'get',
    headers: {
      'USER': userId
    },
  })
}
